package com.elitesland.metadata.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author mir
 * @date 2020-11-21 02:25:20
 */
@Entity
@Table(name = "meta_table")
@org.hibernate.annotations.Table(appliesTo = "meta_table", comment = "元数据表定义")
@Data
@Accessors(chain = true)
@ApiModel(value = "元数据表定义", description = "元数据表定义")
public class MetaTableDO extends BaseModel implements Serializable {

    private static final long serialVersionUID = -4425933583367957816L;

    @ApiModelProperty(value = "表编码")
    @Comment("表编码")
    @Column(nullable = false, unique = true)
    String tableCode;

    @ApiModelProperty(value = "表名称")
    @Comment("表名称")
    @Column()
    String tableName;

    @ApiModelProperty(value = "表前缀")
    @Comment("表前缀")
    @Column()
    String prefix;

    @ApiModelProperty(value = "表描述")
    @Comment("表描述")
    @Column()
    String tableComment;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof MetaTableDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        MetaTableDO entity = (MetaTableDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}